package com.design.graduation.asdemo.application;

/**
 * Created by lijinyuan on 16/2/16.
 */
public class Version {

    public static enum DebugOrRelease {
        DEBUG, RELEASE
    }

    public static enum ApiSource {
        INTRANET, EXTRANET
    }

    private Version() {
    }

    private static DebugOrRelease sDebugOrRelease;

    private static ApiSource sApiSource;

    private static boolean sInitialized;

    public static void init(final DebugOrRelease debugOrRelease,
                            final ApiSource apiSource) {
        if (sInitialized) {
            throw new IllegalStateException("Already initialized!");
        }

        sDebugOrRelease = debugOrRelease;
        sApiSource = apiSource;

        sInitialized = true;
    }

    public static DebugOrRelease getDebugOrRelease() {
        validate();
        return sDebugOrRelease;
    }

    public static ApiSource getApiSource() {
        validate();
        return sApiSource;
    }

    private static void validate() {
        if (!sInitialized) {
            throw new IllegalStateException("Not initialized!");
        }
    }
}
